/**
 * Created by Apple on 2017/7/15.
 */
window.onload = function () {
    $(".nav_show").click(function () {
        $(".submenu").fadeToggle("500", "linear");
    })
    $(".nav li").click(function () {
        $(".nav li").removeClass("nav_active");
        $(this).toggleClass("nav_active")
    })

//    轮播
    var width, lenght, oOl;
    var times, lf = 0, num = 0;

    function oWidth() {
        width = document.body.clientWidth;
        lenght = $(".banner ul>li").length;
        console.log(width);
        console.log(lenght);
        $(".banner ul").css({width: width * lenght + "px"})
        $(".banner ul>li").css({width: width + "px"})
        $(".dot").css({"margin-left": -10 * (lenght - 1) + "px"})
    }

    function banner() {
        oWidth();
        times = setInterval(function () {
            lf += width;
            var max = width * lenght - width
            if (lf == max) {
                lf = 0
            }
            if (lf % width == 0) {
                num++;
                if (num == lenght - 1) {
                    num = 0;
                }
            }
            console.log(num)
            $(".dot>li").removeClass("dot_active");
            $(".dot>li").eq(num).addClass("dot_active");

            $(".banner ul").css({"margin-left": -lf + "px"})

        }, 2000)

    }

    banner();

    $(".dot>li").click(function () {
        // banner()
        clearInterval(times);
        num = $(this).index();
        lf = num * width;
        $(".dot>li").removeClass("dot_active");
        $(".dot>li").eq(num).addClass("dot_active");
        $(".banner ul").css({"margin-left": -lf + "px"});
        banner()
    })


//    底部轮播按钮
    $(".boult").click(function () {
        $(".boult").css({color: "#e1e1e1"})
        $(this).css({color: "#55a7ed"})
    })
//  底部轮播宽
    var len = $(".list_ul2 li").length;
    $(".list_ul2").css({"width": len * 350 + "px"})

    var oLtLf = 0, ind = 0;
    $("#lt2_btn_lf").click(function () {
        oLtLf += 1060;
        ind++;
        if (ind >= (len / 3)) {
            oLtLf = 2120
            ind = len / 3;
        }
        console.log("***********" + ind + "***************")
        $(".list_ul2").css({"transform": "translateX(" + -oLtLf + "px)"})

    })
    $("#lt2_btn_rg").click(function () {
        oLtLf -= 1060;
        ind--;
        if (ind <= 0) {
            oLtLf = 0
            ind = 1;
        }
        console.log("NNNNNNNNNNNNNNN")

        console.log(ind)
        console.log("NNNNNNNNNNNNNNN")

        $(".list_ul2").css({"transform": "translateX(" + -oLtLf + "px)"})

    })

}

